#!/usr/bin/env node

import axios from "axios";
import chalk from "chalk";
import { Command } from "commander";

const program = new Command();

program.version("1.0.0").description("天气查询 CLI 工具").parse(process.argv);

const { city } = program.opts();

// 获取天气数据的函数
async function getWeather(city) {
  try {
    const res = await axios.get(`https://tianqi.qq.com/index.htm`);

    console.log(res);
  } catch (error) {
    console.error(chalk.red("❌ 获取天气失败，请检查城市名称或网络情况。"));
  }
}

getWeather(city);
